<?php
App::uses('AppController', 'Controller');
/**
 * Admin Controller
 *
 * @property Admin $Admin
 * @property PaginatorComponent $Paginator
 */
class AdminController extends AppController {

	public $layout = 'admin';

	public function beforeFilter()
	{
		parent::beforeFilter();
		$user = $this->UserAuth->getUser();
		if($user['User']['role'] != 'admin'){
			$this->error("没有权限进入!");
			$this->redirect("/Users/login");
		}
	}

	/**
	 * 管理员首页
	 */
	public function index()
	{
		$this->loadModel('User');
		$this->loadModel("Order");
		$last_users = $this->User->getLast(5);
		$last_orders = $this->Order->getLast(5);

		$this->set(compact('last_users','last_orders','order_type_arr'));
	}

}
